package com.stellar.auth.controller.admin.authUserRole;

import com.stellar.auth.controller.admin.authUserRole.vo.AuthUserRoleRequestPageVO;
import com.stellar.auth.controller.admin.authUserRole.vo.AuthUserRoleRequestVO;
import com.stellar.auth.controller.admin.authUserRole.vo.AuthUserRoleResponseVO;
import com.stellar.auth.domain.authUserRole.AuthUserRoleDomainService;

import com.stellar.web.core.bean.PageResult;
import com.stellar.web.core.bean.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 用户角色关联表控制器
 * @author Jqchan
 * @version 1.0
 * @date 2025-05-16 18:07:44
 */
@RequestMapping("/api-admin/authUserRole")
@RestController("adminAuthUserRoleController")
@Slf4j
public class AuthUserRoleController {

    @Resource
    private AuthUserRoleDomainService authUserRoleDomainService;

    /**
     * 分页查询用户角色关联表
     */
    @PostMapping("/page")
    public Result<PageResult<AuthUserRoleResponseVO>> page(@RequestBody AuthUserRoleRequestPageVO requestPageVO) {
        return Result.success(authUserRoleDomainService.page(requestPageVO));
    }

    /**
     * 新增用户角色关联表
     */
    @PostMapping("/create")
    public Result<Boolean> create(@RequestBody AuthUserRoleRequestVO requestVO) {
        return Result.success(authUserRoleDomainService.insert(requestVO));
    }

    /**
     * 修改用户角色关联表
     */
    @PostMapping("/update")
    public Result<Boolean> update(@RequestBody AuthUserRoleRequestVO requestVO) {
        return Result.success(authUserRoleDomainService.update(requestVO));
    }

    /**
     * 删除用户角色关联表
     */
    @DeleteMapping("/delete/{id}")
    public Result<Boolean> delete(@PathVariable("id") Long id) {
        return Result.success(authUserRoleDomainService.delete(id));
    }

    /**
     * 获取用户角色关联表详情
     */
    @GetMapping("/get/{id}")
    public Result<AuthUserRoleResponseVO> get(@PathVariable("id") Long id) {
        return Result.success(authUserRoleDomainService.get(id));
    }
}
